<template>
	<view>
		<view class="box">
			<view class="box2">
				<image class="img-box" src="../../static/images/ymy/A30/A30_banner.png"></image>
			</view>
			<view class="beauty_box">
				<image class="beauty_img" src="../../static/images/ymy/A30/logo_audi.png"></image>
				<text class="beauty_text">大众奥迪A6L新能源</text>
				<navigator class="beayty_a">更换车辆 〉</navigator>
			</view>
		</view>
		<view class="beauty_tbBox">
			<view class="beauty_tbBox2" v-for="item in err" :key="item.id" @click='getTab(item.id)'>
				<image class="beauty_tbImg" :src="item.src"></image>
				<text class="beauty_tbText">{{item.name}}</text>
			</view>
		</view>
		<view class="box">
			<!-- 上面动态切换 -->
			<view class="title-view">
				<text v-for="item in list" :class="{buttonActive: switchBtnTab === item.id}"
					@click="switchCurve(item.id)" class="iten" :key='item.id'>
					{{item.name}}
				</text>
			</view>

			<!-- 下面滑块 -->
			<view>
				<view v-for="item in goodlist" :key="item.id" class="text" v-show="switchBtnTab == item.serviceTypeId">
					<view>
						<view class="item">
							<view class="beauty_box1">
								<view>
									<image v-if="item.shopImg == null" class="beauty_img1"
										src="../../static/images/ymy/A30/image_mr.png"></image>
									<image v-if="item.shopImg != null" class="beauty_img1" :src="item.shopImg"></image>
								</view>
								<view class="beauty_box4">
									<navigator class="beauty_text2" url="../../pages/carBeauty/carBeauty"
										@click="storeHome(item.shopId)">
										{{item.shopName}}
									</navigator>
									<view>
										<view class="beauty_box2">
											<view class="xx_baox">
												<image class="beauty_img2" src="../../static/icons/ymy/icon_xx.png">
												</image>
												<image class="beauty_img2" src="../../static/icons/ymy/icon_xx.png">
												</image>
												<image class="beauty_img2" src="../../static/icons/ymy/icon_xx.png">
												</image>
												<image class="beauty_img2" src="../../static/icons/ymy/icon_xx.png">
												</image>
												<image class="beauty_img2" src="../../static/icons/ymy/icon_xx.png">
												</image>
											</view>
											<view class="beauty_pf">{{item.prestige}}分</view>
											<view class="beauty_pl"><text
													class="beauty_sz">{{item.judgementTotal}}</text>条评论</view>
										</view>
										<view>

											<text class="beauty_bq1">免费停车</text>
										</view>
										<view class="beauty_box3">
											<view class="beauty_text">
												<view class="beauty_text3">
													<p class="beauty_p">￥</p>
													{{item.price}}
												</view>
												<text class="beauty_bq">vip</text>
											</view>
											<view class="beauty_button" @click="buy(item)">
												购买
											</view>
										</view>
									</view>
								</view>
							</view>
							<view class="text_zx"></view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		createNamespacedHelpers
	} from "vuex";
	let {
		mapState,
		mapActions
	} = createNamespacedHelpers("carBeauty");
	export default {
		props: ['id'],
		data() {
			return {
				err: [{
						id: 1,
						src: require("../../static/icons/ymy/icon_sd.png"),
						name: "洗车",
						status: 10,
						pid: 0
					},
					{
						id: 2,
						src: require("../../static/icons/ymy/icon_fxp.png"),
						name: '内饰美容',
						status: 10,
						pid: 0
					},
					{
						id: 3,
						src: require("../../static/icons/ymy/icon_mr.png"),
						name: '粘膜',
						status: 10,
						pid: 0
					},
					{
						id: 4,
						src: require("../../static/icons/ymy/icon_bs.png"),
						name: '车身修复',
						status: 10,
						pid: 0
					},
					{
						id: 19,
						src: require("../../static/icons/ymy/icon_hp.png"),
						name: '车身改色',
						status: 10,
						pid: 0
					}
				],
				switchBtnTab: 12,
				swiper: [],
				list: [],
				goodlist: [],
				idlist: {
					id: 0,
					_id: 0,
					lng: '109.1954',
					lat: '34.6592'
				},
				goods: {
					userId: '',
					serviceInfoId: '',
					serviceInfoName: '',
					totalPrice: '',
					serviceInfoImg: ''
				}
			}
		},
		mounted() {
			this.getTab(1);
			this.switchCurve(12)
			// this.getBeautyNavigation({
			// 	swiper:this.store
			// })
		},
		onLoad(options) {
			this.getBeautyGoodList({
				goodsId: options.id
			})
			this.goodsid = options.id - 0
		},
		computed: {
			...mapState(["store"])
		},
		methods: {
			...mapActions(["getBeautyNavigation", "getBeautyGoodList", "getStoreHome", "postBuy"]),
			async switchCurve(index) {
				this.switchBtnTab = index;
				const data = await this.getBeautyGoodList(index);
				this.goodlist = data
				console.log(this.goodlist, 123)
			},
			async getTab(id) {
				// console.log(id)
				const data = await this.getBeautyNavigation(id);
				this.swiper = data.data;
				this.list = data.type;
				this.idlist._id = id
				console.log(data, 1234)
			},
			//购买
			async buy(val) {
				const _id = uni.getStorageSync('id')
				this.goods.userId = _id;
				this.goods.serviceInfoId = val.serviceTypeId;
				this.goods.serviceInfoName = val.serviceInfoName;
				this.goods.totalPrice = val.price;
				this.goods.serviceInfoImg = val.shopImg;
				const data = await this.postBuy(this.goods);
				if (data.result == true && _id) {
					uni.navigateTo({
						url: `/pages/serviceOeder/serviceOrder?tada=${val.id}&_id=12`
					})
				} else {
					uni.navigateTo({
						url:'/pages/loginLx/loginLx'
					})
				}
			},
			storeHome(id) {
				this.idlist.id = id
				// console.log(this.idlist,123)
				this.getStoreHome(this.idlist)
			},
			spxq(data) {
				this.getBeautyGoodList(data)
			},
		}
	}
</script>

<style>
	.box {
		padding: 0 30rpx;
	}

	.box2 {
		position: absolute;
		top: 184rpx;
	}

	.img-box {
		width: 690rpx;
		height: 184rpx;
		border-radius: 20rpx;
		background-color: #007AFF;
		margin: 10rpx 0;
	}

	.beauty_box {
		width: 690rpx;
		height: 90rpx;
		background-color: #ffffff;
		border-radius: 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 164rpx;
	}

	.beauty_img {
		width: 88rpx;
		height: 88rpx;
		margin-left: 30rpx;
	}

	.beauty_tbBox {
		display: flex;
		justify-content: space-around;
		background-color: #FFFFFF;
		margin-top: 20rpx;
	}

	.beauty_tbBox2 {
		width: 80rpx;
		display: flex;
		justify-content: center;
		flex-wrap: wrap;
		padding: 20rpx 0;
	}

	.xx_baox {
		display: flex;
	}

	.beauty_tbImg {
		width: 80rpx;
		height: 80rpx;
	}

	.beauty_tbText {
		font-family: PingFang SC;
		font-size: 20rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 28rpx;
		letter-spacing: 0rpx;
		color: rgba(0, 0, 0, 1);
	}

	.beauty_box5 {
		width: 750rpx;
		height: 954rpx;
		background-color: #ffffff;
		border-radius: 20rpx;
	}

	.beauty_text {
		height: 40rpx;
		font-weight: bold;
		font-stretch: normal;
		line-height: 40rpx;
		letter-spacing: 0rpx;
		color: #000000;
		display: flex;
		align-items: center;
	}

	.beayty_a {
		padding-right: 30rpx;
		font-family: PingFang SC;
		font-size: 20rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 28rpx;
		letter-spacing: 0rpx;
		color: #797979;
	}

	.text-view {
		width: 96rpx;
		height: 34rpx;
		flex-grow: 1;
		text-align: center;
		font-family: PingFang SC;
		font-size: 24rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 34rpx;
		letter-spacing: 0rpx;
		color: #000000;
	}

	.active {
		width: 56rpx;
		height: 40rpx;
		font-family: PingFang SC;
		font-size: 28rpx;
		font-weight: bold;
		font-stretch: normal;
		line-height: 40rpx;
		letter-spacing: 0rpx;
		color: #000000;
	}

	.beauty_box1 {
		width: 664rpx;
		height: 170rpx;
		display: flex;
		margin: 0 30rpx;
	}

	.beauty_text2 {
		font-family: PingFang SC;
		font-size: 28rpx;
		font-weight: bold;
		font-stretch: normal;
		line-height: 40rpx;
		letter-spacing: 0rpx;
		color: #000000;
	}

	.beauty_text3 {
		font-family: PingFang SC;
		font-size: 40rpx;
		font-weight: normal;
		letter-spacing: 0rpx;
		color: #ff0000;
		display: flex;
		margin: 10rpx 10rpx 0 0;
	}

	.beauty_p {
		font-family: PingFang SC;
		font-size: 24rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 56rpx;
		letter-spacing: 0rpx;
		color: #ff0000;
	}

	.beauty_box4 {
		width: 522rpx;
		padding-left: 20rpx;
	}

	.beauty_img1 {
		width: 152rpx;
		height: 152rpx;
	}

	.beauty_box2 {
		display: flex;
		align-items: center;
	}

	.beauty_img2 {
		width: 32rpx;
		height: 32rpx;
		margin-left: -12rpx;
	}

	.beauty_pf {
		width: 44rpx;
		height: 26rpx;
		font-family: PingFang SC;
		font-size: 18rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 26rpx;
		letter-spacing: 0rpx;
		color: #929292;
		margin: 0 5rpx;
	}

	.beauty_pl {
		font-family: PingFang SC;
		font-size: 18rpx;
		font-weight: normal;
		letter-spacing: 0rpx;
		color: #929292;
		line-height: 18rpx;
	}

	.beauty_sz {
		font-size: 18rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 26rpx;
		letter-spacing: 0rpx;
		color: #f9b303;
	}

	.beauty_box3 {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.beauty_bq1 {
		height: 26rpx;
		border-radius: 14rpx;
		border: solid 2rpx #919191;
		font-family: PingFang SC;
		font-size: 18rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 26rpx;
		letter-spacing: 0rpx;
		color: #595959;
		padding: 0 10rpx;
	}

	.beauty_bq {
		width: 84rpx;
		height: 26rpx;
		border-radius: 14rpx;
		border: solid 2rpx #ff0000;
		font-family: PingFang SC;
		font-size: 18rpx;
		font-weight: normal;
		font-stretch: normal;
		letter-spacing: 0rpx;
		color: #ff0000;
		text-align: center;
		line-height: 16rpx;
	}

	.beauty_button {
		width: 120rpx;
		height: 44rpx;
		background-color: #f5610c;
		border-radius: 24rpx;
		font-family: PingFang SC;
		font-size: 20rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 44rpx;
		letter-spacing: 0rpx;
		color: #ffffff;
		text-align: center;
		margin-right: 20rpx;
	}

	.iten {
		height: 44rpx;
		font-family: PingFang SC;
		font-size: 32rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 11rpx;
		letter-spacing: 0rpx;
		color: #4a4a4a;
		padding: 36rpx 0;
		margin: 0 0 0 36rpx;
	}

	.item {
		background-color: #FFFFFF;
		margin-bottom: 20rpx;
	}

	.buttonActive {
		border-bottom: 4rpx solid #f5610c;
		border-radius: 4rpx;
	}

	.commets_swiper {
		background-color: #FFFFFF;
		height: 100vh;
	}

	.commets_bt {
		margin: 20rpx 0 0 30rpx;
	}

	.commets_img {
		width: 120rpx;
		height: 120rpx;
		background-color: #000000;
	}

	.commets_text_box {
		display: flex;
		margin: 30rpx 30rpx 10rpx 30rpx;
	}

	.commets_text {
		line-height: 30rpx;
		margin: 0 30rpx;
	}

	.commets_spm {
		margin-top: 30rpx;
		font-family: PingFang SC;
		font-size: 20rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 28rpx;
		letter-spacing: 0rpx;
	}

	.title-view {
		display: flex;
		background-color: #FFFFFF;
		padding-bottom: 20rpx;
		margin-top: 20rpx;
	}

	.text-view {
		flex-grow: 1;
		line-height: 80rpx;
		text-align: center;
	}

	.active {
		border-bottom: 5rpx solid #5992BD;
	}

	.commets_pj {
		height: 45rpx;
		text-align: right;
		margin-right: 30rpx;
		line-height: 45rpx;
	}

	.commets_text_pj {
		width: 140rpx;
		height: 48rpx;
		padding: 5rpx 35rpx;
		line-height: 40rpx;
		color: #f5610c;
		border: 1rpx solid #f5610c;
		border-radius: 24rpx;
		font-family: PingFang SC;
		font-size: 20rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 28rpx;
		letter-spacing: 0rpx;
	}

	.text_zx {
		width: 656rpx;
		height: 0rpx;
		border: solid 1rpx #d4d4d4;
		margin-left: 15rpx;
	}

	.text {
		background-color: #FFFFFF;
	}
</style>
